package com.example.leave.common;

import com.example.leave.form.PageInfoForm;
import com.example.leave.pojo.Sort;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Page;

import java.util.List;

@Data
public class CommonPage<T> extends PageInfoForm {
    int totalPages;

    long totalElements;

    List<T> content;

    public static <T> CommonPage<T> getCommonPage(Page page, Sort sort) {
        CommonPage<T> commonPage = new CommonPage<>();
        BeanUtils.copyProperties(page, commonPage);
        commonPage.setSort(sort);
        return commonPage;
    }
}
